package com.lufei.dh.bottom.Fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.lufei.dh.R;
import com.lufei.dh.bottom.MultAuto.Item_Auto;
import com.lufei.dh.bottom.MultAuto.Item_AutoViewBinder;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;
import me.drakeet.multitype.Items;
import me.drakeet.multitype.MultiTypeAdapter;

/**
 * 版权：易金卡沃 版权所有
 * <p>
 * 作者：lufei
 * <p>
 * 创建日期：2018/6/25
 * <p>
 * 描述：
 * <p>
 * 修订历史：
 */
public class Fragment4 extends Fragment {

    private MultiTypeAdapter adapter;
    private Items items;
    @BindView(R.id.f3_recyclerview)
    RecyclerView f3Recyclerview;
    Unbinder unbinder;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = LayoutInflater.from(getActivity()).inflate(R.layout.fragment3, container, false);
        unbinder = ButterKnife.bind(this, view);
        init();
        return view;
    }

    private void init() {
        f3Recyclerview.setLayoutManager(new LinearLayoutManager(getContext()));
        adapter=new MultiTypeAdapter();
        adapter.register(Item_Auto.class, new Item_AutoViewBinder(getContext()));
        items = new Items();
        int size = 30;
        for (int i = 0; i < size; i++) {
            items.add(new Item_Auto("数据" + i,i));
        }
        adapter.setItems(items);
        f3Recyclerview.setAdapter(adapter);
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }
}
